#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef long double ldb;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back
#define vec vector<int>

int read(){int x = 0,sgn = 1;char ch = getchar();for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);return x*sgn;}

const int N = 1e5+10;

struct edge{int v,nxt;}e[N<<1];
int n,m,p[N],b[N],h[N],cnt,fa[N],q;
int s[N<<6],ls[N<<6],rs[N<<6],ndn,ind[N],stk[N],rtop,siz[N],rt[N];
void link(int x,int y){e[++cnt] = (edge){y,h[x]};h[x] = cnt;}

int gf(int x){return fa[x] == x ? x : fa[x] = gf(fa[x]);}

int newnode(){if(rtop) return stk[rtop--]; return ++ndn;}

void upd(int &o,int v,int l = 1,int r = n){
	if(!o) o = newnode(); s[o]++; if(l == r) return; int mid = l + r >> 1;
	if(v <= mid) upd(ls[o],v,l,mid); else upd(rs[o],v,mid+1,r);
}

int query(int o,int k,int l = 1,int r = n){
	if(l == r) return l; int mid = l + r >> 1;
	if(s[ls[o]] < k) return query(rs[o],k - s[ls[o]],mid + 1,r);
	else return query(ls[o],k,l,mid);
}

void merge(int &y,int x,int l = 1,int r = n){
	if(!x || !y) return y = x + y,void(); s[y] = s[x] + s[y];
	if(l == r) return ls[x] = rs[x] = s[x] = 0,stk[++rtop] = x,void(); int mid = l + r >> 1;
	merge(ls[y],ls[x],l,mid); merge(rs[y],rs[x],mid + 1,r);
	stk[++rtop] = x; ls[x] = rs[x] = s[x] = 0;
}

void mergetree(int x,int y){
	x = gf(x); y = gf(y); if(x == y) return;
	if(siz[x] < siz[y]) swap(x,y);
	merge(rt[x],rt[y]); siz[x] += siz[y]; fa[y] = x;
}

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in,m = in; for(int i = 1;i <= n;i++) b[i] = p[i] = in; sort(b + 1,b + n + 1);
	for(int i = 1;i <= n;i++) p[i] = lower_bound(b + 1,b + n + 1,p[i]) - b,ind[p[i]] = i;
	for(int i = 1;i <= n;i++) upd(rt[i],p[i]),fa[i] = i,siz[i] = 1;
	for(int i = 1,u,v;i <= m;i++) u = in,v = in,mergetree(u,v);
	q = in;
	for(int i = 1;i <= q;i++){
		char op = getchar(); while(!isalpha(op)) op = getchar(); int x = in,y = in;
		if(op == 'B') mergetree(x,y);
		else printf("%d\n",siz[gf(x)] < y ? -1 : ind[query(rt[gf(x)],y)]);
	}
	return 0;
}
